import React, { Component } from 'react';
import { StyleSheet, Text, View, Dimensions, Image, TouchableOpacity, TextInput } from "react-native";
import { style } from '../../../../../theme/style';
import { offerStyle } from './offerStyle';
import DateGapPicker from '../../../../../components/common/DateGapPicker';


const ScreenWidth = Dimensions.get('window').width;
const scale = ScreenWidth / 375;

export class TimeDayCpt extends Component {

	constructor(props) {
		super(props);
		let { data } = props || {};
		console.log('data-时间-123', data)
		this.state = {
			showTimeModal: false,
			other: data
		}
		this.onoffBtn = false;
	}

	componentWillReceiveProps (props) {
		// if (!props) return;
		// let { data } = props || {};
		// let { selectKey } = data || {};
		// this.state = {
		// 	selectKey,
		// 	showTimeModal: false
		// }
	}
	//
	_resultCall = (data) => {
		let { other } = this.state || {};
		let { idStaet, idEnd } = other || {};
		let { event } = this.props;
		let { planeCallback } = event || {};
		other.valueStart = data.startDate;
		other.valueEnd = data.endDate;
		this.setState({
			showTimeModal: false,
			other
		}, () => {
			console.log('1230', other)
			planeCallback && planeCallback({ [idStaet]: data.startDate, [idEnd]: data.endDate });
		})
	}

	render () {
		let { showTimeModal, other } = this.state || {};
		let { valueStart, valueEnd } = other || {};
		let dateObj = {
			startDate: null,
			endDate: null
		};
		return (
			<TouchableOpacity onPress={() => { this.setState({ showTimeModal: true }) }} style={[offerStyle.row, offerStyle.other, offerStyle.otherTimeDay, { justifyContent: 'space-around' }]}>
				<Text style={[offerStyle.otherValue, offerStyle.fontBold]}>{valueStart || ''}</Text>
				<Text style={offerStyle.otherLay}>至</Text>
				<Text style={[offerStyle.otherValue, offerStyle.fontBold]}>{valueEnd || ''}</Text>
				{/* {
					showTimeModal ? <RangTime isVisible={true} markedDates={null} closeCall={() => { this.setState({ showTimeModal: false }) }} resultCall={this._resultCall} /> : null
				} */}

				<DateGapPicker
					isVisible={showTimeModal}
					date={dateObj}
					double={true}
					cb={(newDate) => {
						newDate && this._resultCall(newDate)
					}} />

			</TouchableOpacity>
		)
	}
}

const styles = StyleSheet.create({

})